local hx__jici = fk.CreateSkill{
  name = "hx__jici",
  tags = { Skill.Compulsory },
}


hx__jici:addEffect(fk.PindianFinished, {
  anim_type = "negative",
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return (player == data.from or data.results[player]) and player:hasSkill(hx__jici.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:notifySkillInvoked(player, hx__jici.name)
    if player == data.from then
      if data.fromCard.number ~= 1 then
        local a = math.random(1, 2)
        if a == 1 then
          player:broadcastSkillInvoke(hx__jici.name, 1)
          player:chat("谅尔等腐草之荧光，如何比得上天空之皓月？")
        else
          player:broadcastSkillInvoke(hx__jici.name, 2)
          player:chat("你……诸葛村夫，你敢！")
        end
        room:changeMaxHp(player, -1)
      else
        if #player:getPile("$hx__raoshe") < 7 then
          local targets = table.simpleClone(data.tos)
          table.insert(targets, data.from)
          local deathplayer = table.random(targets)
          if deathplayer == player then
            player:broadcastSkillInvoke(hx__jici.name, 2)
            player:chat("你……诸葛村夫，你敢！")
          else
            player:broadcastSkillInvoke(hx__jici.name, 1)
            player:chat("谅尔等腐草之荧光，如何比得上天空之皓月？")
          end
          room:killPlayer({ who = deathplayer })
        end
      end
    elseif data.results[player] then
      if data.results[player].toCard.number ~= 1 then
        player:broadcastSkillInvoke(hx__jici.name)
        room:changeMaxHp(player, -1)
      else
        if #player:getPile("$hx__raoshe") < 7 then
          local targets = table.simpleClone(data.tos)
          table.insert(targets, data.from)
          local deathplayer = table.random(targets)
          if deathplayer == player then
            player:broadcastSkillInvoke(hx__jici.name, 2)
            player:chat("你……诸葛村夫，你敢！")
          else
            player:broadcastSkillInvoke(hx__jici.name, 1)
            player:chat("谅尔等腐草之荧光，如何比得上天空之皓月？")
          end
          room:killPlayer({ who = deathplayer })
        end
      end
    end
  end,
})

return hx__jici
